package lol.clann.minecraft.springboot.api.bukkit.utils;

import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.util.Vector;

/**
 * 涉及到BlockPosition的方法,都只能在1.8+调用
 *
 * @author pyz
 * @date 2019/5/12 10:44 PM
 */
public interface LocationUtils {

    default public Location toLocation(World world, double x, double y, double z) {
        return new Location(world, x, y, z);
    }

    /**
     * 创建BlockPosition
     *  1.8+
     *
     * @param x
     * @param y
     * @param z
     * @param <T>
     * @return
     */
    <T> T newBlockPosition(int x, int y, int z);

    /**
     * Location转换成BlockPosition
     * @param location
     * @param <T>
     * @return
     */
    <T> T toBlockPosition(Location location);

    /**
     * BlockPosition转换成Location
     * @param world
     * @param blockPosition
     * @param <T>
     * @return
     */
    <T> Location toLocation(World world, T blockPosition);

    /**
     * 序列化成NBTtagCompound
     * @param location
     * @param <T>
     * @return
     */
    <T> T toNBTTagCompound(Location location);

    /**
     * 向当前方向移动指定距离
     *
     * @param distance
     * @return
     */
    void forward(Location now, double distance);

    /**
     * 向指定方向移动
     *
     * @param now
     * @param direction
     * @param distance
     */
    void forward(Location now, Vector direction, double distance);
}
